Re-opening Closures

نویسنده

  • Andrew W. Appel
چکیده

There are two different commonly-used evaluation methods for functional languages: normal-order graph reduction, and call-by-value execution of closure code. The former is usually more expensive per operation, but has the capability of partially evaluating functions before they are applied. The latter method usually leads to faster execution — and is thus used in most compilers — but can’t ‘‘optimize’’ functions before they are called. The different advantages of the two methods are particularly visible in the evaluation of higher-order functions. After a higher-order function is applied to one argument, the graph-reducer can begin evaluation, while the closure-code evaluator must wait until all arguments are present. On the other hand, because the closure-code evaluator executes the native code of the computer, it usually outperforms the graph-reducer. The two evaluation algorithms can be combined to take advantage of the best behaviors of both. Fragments from programs that are already executing can be extracted, reduced, and re-compiled. This is done with an operator, reduce, that is semantically transparent: — reduce( f ) does not change the behaviour of the program fragment f, but can make f much more efficient. This applies not just to functions f in the original program, but to functions constructed at runtime. 1. Higher-order functions The notion of a higher-order function (a function that returns another function as a result) is present in many functional languages, but it is often found in conventional languages as well. For example, the C programming language has no built-in notion of higher-order functions, but there are many softwaredevelopment tools (like the parser generator YACC[1]) that produce C programs as their output. It is inconvenient, inefficient, and ugly to implement higher-order functions by producing source code; so the very fact that it has been done repeatedly shows how important higher-order functions are. Functional languages based on lambda-calculus have an inherent notion of higher-order function, so that they may be programmed in the language directly, without resorting to the output of source code to be fed back into the compiler. This is a great advantage, since now functions like parser generators can be implemented as a higher-order function completely inside the language, perhaps with the type: PG: Grammar → (String → ParseTree) The parser-generator PG can then be applied to a grammar, yielding a parser P : P = PG(MyGrammar) This step may take a nontrivial amount of time, as it involves the construction of parsing tables. Once it is done, however, the parser P may be applied to many different input strings, without executing PG for each one.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Normal and inhomogeneous moment closures for stochastic process algebras

This paper discusses the application of moment closures to continuous Markov chains derived from process algebras such as GPEPA and MASSPA. Two related approaches are being investigated. Firstly we re-formulate normal moment closure in a process algebra framework using Isserlis’ theorem. Secondly we apply a mixture of this normal closure and less precise moment closures for the purpose of reduc...

متن کامل

Capsaicin activation of the pain receptor, VR1: multiple open states from both partial and full binding.

Capsaicin, the pungent ingredient of hot peppers, has long been used to identify nociceptors. Its molecular target, the vanilloid receptor VR1, was recently cloned and confirmed functionally as a polymodal detector of multiple pain stimuli: heat, acid, and vanilloids. Previous electrophysiology studies have focused on whole-cell characteristics of the receptor. Here, we provide the first in-dep...

متن کامل

Optimal Prediction for Moment Models: Crescendo Diffusion and Reordered Equations

A direct numerical solution of the radiative transfer equation or any kinetic equation is typically expensive, since the radiative intensity depends on time, space and direction. An expansion in the direction variables yields an equivalent system of infinitely many moments. A fundamental problem is how to truncate the system. Various closures have been presented in the literature. We want to st...

متن کامل

Optimal Prediction for Radiative Transfer: a New Perspective on Moment Closure

A direct numerical solution of the radiative transfer equation is typically expensive, since the radiative intensity depends on time, space and direction. An expansion in the direction variables yields an equivalent system of infinitely many moments. A fundamental problem is how to truncate the system. Various closures have been presented in the literature. We formulate the method of optimal pr...

متن کامل

Performance characteristics of a novel blood bag in-line closure device and subsequent product quality assessment

BACKGROUND In high-volume processing environments, manual breakage of in-line closures can result in repetitive strain injury (RSI). Furthermore, these closures may be incorrectly opened causing shear-induced hemolysis. To overcome the variability of in-line closure use and minimize RSI, Fresenius Kabi developed a new in-line closure, the CompoFlow, with mechanical openers. STUDY DESIGN AND M...

متن کامل

Transcatheter Closures for Fistula Tract and Paravalvular Leak after Mitral Valve Replacement and Tricuspid Annuloplasty

Paravalvular leaks (PVLs) often occur after surgical valve replacement. Surgical reoperation has been the gold standard of therapy for PVLs, but it carries a higher operative risk and an increased incidence of re-leaks compared to the initial surgery. In high surgical risk patients with appropriate geometries, transcatheter closure of PVLs could be an alternative to redo-surgery. Here, we repor...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 1988